# $Id$
# Maintainer: Eric Bélanger <eric@archlinux.org>

pkgbase=msmtp
pkgname=('msmtp' 'msmtp-mta')
pkgver=1.6.6
pkgrel=1
pkgdesc="A mini smtp client"
arch=('i686' 'x86_64')
url="http://msmtp.sourceforge.net"
license=('GPL3')
makedepends=('texlive-plainextra' 'gsasl' 'libsecret')
source=(http://download.sourceforge.net/sourceforge/msmtp/${pkgbase}-${pkgver}.tar.xz)
sha1sums=('f997f40dfb3f882df837cfd9a63bd4d271dcdc41')

build() {
  cd ${pkgbase}-${pkgver}
  ./configure --prefix=/usr --sysconfdir=/etc --with-ssl=gnutls
  make
  make -C doc html pdf
}

package_msmtp() {
  pkgdesc="A mini smtp client"
  depends=('gsasl' 'libsecret')

  cd ${pkgbase}-${pkgver}
  make DESTDIR="${pkgdir}" install 
  make DESTDIR="${pkgdir}" -C doc install-html install-pdf

# Installing example configs and scripts to /usr/share/doc/msmtp
# as they are not installed by default (Debian and Gentoo do it this way)
  install -d "${pkgdir}/usr/share/doc/msmtp"
  cp -r scripts/{find_alias,msmtpqueue,msmtpq,set_sendmail} "${pkgdir}/usr/share/doc/msmtp/"
  install -D -m644 doc/*.example "${pkgdir}/usr/share/doc/msmtp/"

  install -D -m644 scripts/vim/msmtp.vim "${pkgdir}/usr/share/vim/vimfiles/syntax/msmtp.vim"
}

package_msmtp-mta() {
  pkgdesc="A mini smtp client - the regular MTA"
  depends=('msmtp')
  provides=('smtp-forwarder')
  conflicts=('smtp-forwarder')

  install -d "${pkgdir}"/usr/bin
  ln -s msmtp "${pkgdir}/usr/bin/sendmail"
}
